package com.lord.otter.component.infrastructure.retry.domain;

import cn.hutool.core.util.IdUtil;
import com.lord.otter.component.infrastructure.retry.constant.ExecStatus;
import lombok.Data;

import java.util.Date;

/**
 * http 重试信息
 *
 * @author lord
 * 2025/8/8 17:50
 */
@Data
public class HttpRetryInfo {
    /**
     * 任务id
     */
    private Long id;

    /**
     * 请求结果
     */
    private String responseBody;

    /**
     * 执行时间
     */
    private Date execTime;

    /**
     * 执行错误信息
     */
    private String execErrorMessage;

    /**
     * 执行状态
     */
    private ExecStatus execStatus;

    public static HttpRetryInfo create(Date execTime) {
        HttpRetryInfo domain = new HttpRetryInfo();
        domain.setId(IdUtil.getSnowflakeNextId());
        domain.setExecTime(execTime);
        domain.setExecStatus(ExecStatus.NOT_STARTED);
        return domain;
    }
}
